project(Kiva)

cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 17)

# set(Python_ADDITIONAL_VERSIONS 3.6)
# find_package(PythonLibs REQUIRED)
# find_package(PythonInterp REQUIRED)
# message(STATUS ${PYTHON_INCLUDE_DIRS})

include_directories(${PYTHON_INCLUDE_DIRS})

# set(BUILD_SHARED_LIBS On)

add_custom_command(OUTPUT kiva/builtin_names.h
    COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/builtin_names_gen.py
    ${CMAKE_BINARY_DIR}/kiva/builtin_names.h
    DEPENDS ${CMAKE_SOURCE_DIR}/src/builtin_names_gen.py 
    ${CMAKE_SOURCE_DIR}/src/builtin_names.h.mako
)

include_directories(${CMAKE_BINARY_DIR})
include_directories(src)

# add_subdirectory(src/third_party/googletest)
find_package(GTest)
include_directories(GTEST_INCLUDE_DIR)

# add_subdirectory(src/third_party/glog)

add_subdirectory(src/third_party/pybind11)
include_directories(src/third_party/pybind11/include)

add_subdirectory(src/third_party/pyast11)
include_directories(src/third_party/pyast11/src)

add_library(kiva 
    src/kiva/parser.cc
    src/kiva/node.cc
    src/kiva/dsl.cc
    ${CMAKE_BINARY_DIR}/kiva/builtin_names.h
)
  
target_link_libraries(kiva ${PYTHON_LIBRARIES} pyast11 glog)

include(GoogleTest)

add_executable(kiva_unittests 
    src/kiva/test_main.cc
    src/kiva/parser_unittests.cc
    # src/kiva/node_unittests.cc
    # src/kiva/dsl_unittests.cc
)

target_link_libraries(kiva_unittests gtest_main kiva)

add_executable(test_main2 src/kiva/test_main2.cc)
target_link_libraries(test_main2 kiva)
